import request from '@/utils/request';
import { object2Url } from '@/utils/trans';

// 商家信息新增

// 查询充值/使用记录 （未使用）
export async function addMerchantinfo(data) {
  const res = await request.post(
    '/business/merchantinfo/addMerchantinfo',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
// 商家信息修改
export async function updateMerchantinfo(data) {
  const res = await request.post(
    '/business/merchantinfo/updateMerchantinfo',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
// 获取oemid
export async function getoemAgentInfo(data) {
  const res = await request.post('/business/oemAgent/getoemAgentInfo', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id查询用户
 * @param id 用户id
 */
// export async function getMerchantinfo(params) {
//   const res = await request.get('/business/merchantinfo/getMerchantinfo', {
//     params
//   });
//   if (res.data.code === 0) {
//     return res.data.data;
//   }
//   return Promise.reject(new Error(res.data.message));
// }
// 商家信息详情

export async function getMerchantinfo(data) {
  const res = await request.post(
    '/business/merchantinfo/getMerchantinfo',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  //   return Promise.reject(new Error(res.data.msg));
}
// 添加图片
export async function merchantInformationSaveImg(data) {
  const res = await request.post('/business/merchantsaveimg/addSaveImg', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
//   删除图片
export async function merchantInformationDeleteImg(data) {
  const res = await request.post(
    '/business/merchantsaveimg/deleteSaveImg',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
// 图片列表
export async function merchantInformationPageImg(data) {
  const res = await request.post(
    '/business/merchantsaveimg/getSaveImgList',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
